﻿using System;
using System.Collections;
using System.Collections.Generic;
using GeoAPI.Geometries;
using NetTopologySuite.Operation;

namespace NetTopologySuite.Geometries
{
	[Serializable]
	public class MultiLineString : GeometryCollection, IMultiLineString, IMultiCurve, IGeometryCollection, IGeometry, ICloneable, IComparable, IComparable<IGeometry>, IEquatable<IGeometry>, IEnumerable<IGeometry>, IEnumerable, ILineal
	{
		public MultiLineString(ILineString[] lineStrings, IGeometryFactory factory) : base(lineStrings, factory)
		{
		}

		public MultiLineString(ILineString[] lineStrings) : this(lineStrings, Geometry.DefaultFactory)
		{
		}

		public override Dimension Dimension
		{
			get
			{
				return Dimension.Curve;
			}
		}

		public override Dimension BoundaryDimension
		{
			get
			{
				if (this.IsClosed)
				{
					return Dimension.False;
				}
				return Dimension.Point;
			}
		}

		public override string GeometryType
		{
			get
			{
				return "MultiLineString";
			}
		}

		public override OgcGeometryType OgcGeometryType
		{
			get
			{
				return OgcGeometryType.MultiLineString;
			}
		}

		public bool IsClosed
		{
			get
			{
				if (this.IsEmpty)
				{
					return false;
				}
				for (int i = 0; i < base.Geometries.Length; i++)
				{
					if (!((ILineString)base.Geometries[i]).IsClosed)
					{
						return false;
					}
				}
				return true;
			}
		}

		public override IGeometry Boundary
		{
			get
			{
				return new BoundaryOp(this).GetBoundary();
			}
		}

		public override IGeometry Reverse()
		{
			int num = base.Geometries.Length;
			ILineString[] array = new ILineString[num];
			for (int i = 0; i < base.Geometries.Length; i++)
			{
				array[num - 1 - i] = (ILineString)base.Geometries[i].Reverse();
			}
			return base.Factory.CreateMultiLineString(array);
		}

		IMultiLineString IMultiLineString.Reverse()
		{
			return (IMultiLineString)this.Reverse();
		}

		public override bool EqualsExact(IGeometry other, double tolerance)
		{
			return this.IsEquivalentClass(other) && base.EqualsExact(other, tolerance);
		}

		public new static readonly IMultiLineString Empty = new GeometryFactory().CreateMultiLineString(null);
	}
}
